package com.skytech.component.crawler.task;

import com.skytech.component.crawler.special.HKEXNEWS;
import com.skytech.component.crawler.special.ShanghaiSec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ScheduledTask {
    @Autowired
    private ShanghaiSec shanghaiSec;

    @Autowired
    private HKEXNEWS hkexnews;

    Boolean useShanghaiSec = false;
    Boolean useHKEXNEWS = false;
    private static final Logger log = LoggerFactory.getLogger(ScheduledTask.class);
 /*   @Scheduled(cron = "0 00 02 ? * *")
    public void start(){
        log.debug("定时任务开始");
        if(use) {
            crawlerTask.startChromeTask();
        }
    }*/


    @Scheduled(cron = "0 00 9 ? * *")
    public void startHKEXNEWS() {
        log.debug("定时任务开始");
        if (!useHKEXNEWS) {
            useHKEXNEWS = true;
            hkexnews.start();
            useHKEXNEWS = false;
        } else {
            log.debug("上一个任务未完成");
        }
    }

    @Scheduled(cron = "0 00 11 ? * *")
    public void startShanghaiSec() {
        log.debug("定时任务开始");
        if (!useShanghaiSec) {
            useShanghaiSec = true;
            shanghaiSec.start();
            useShanghaiSec = false;
        } else {
            log.debug("上一个任务未完成");
        }
    }
}
